package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketTopic;
import com.cskaoyan.bean.MarketTopicGoods;
import com.cskaoyan.bean.common.BasePageInfo;
import com.cskaoyan.bean.common.BaseRespVo;
import com.cskaoyan.bean.common.CommonData;
import com.cskaoyan.service.AdminTopicService;
import com.fasterxml.jackson.databind.ser.Serializers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.plugin2.message.MarkTaintedMessage;

import java.util.Map;

/***
 * title AdminTopicController
 * @description <TODO description class purpose>
 * @author ZCZ
 * @version 1.0.0
 * @create 2022/9/11 11:45
 **/
@RestController
@RequestMapping("admin/topic")
public class AdminTopicController {
    @Autowired
    AdminTopicService adminTopicService;

    @RequestMapping("list")
    public BaseRespVo list(BasePageInfo info, String title, String subtitle) {
        CommonData<MarketTopic> data = adminTopicService.list(info, title, subtitle);
        return BaseRespVo.ok(data);
    }

    @RequestMapping("create")
    public BaseRespVo create(@RequestBody  MarketTopic marketTopic) {
        MarketTopic marketTopic1 = adminTopicService.create(marketTopic);
        return BaseRespVo.ok(marketTopic1);
    }

    @RequestMapping("delete")
    public BaseRespVo delete(@RequestBody MarketTopic marketTopic) {
        adminTopicService.delete(marketTopic.getId());
        return BaseRespVo.ok3();
    }
    @RequestMapping("batch-delete")
    public BaseRespVo batchDelete(@RequestBody Map<String,Integer[]> map){
        adminTopicService.batchDelete(map);
        return BaseRespVo.ok3();
    }



    @RequestMapping("update")
    public BaseRespVo update(@RequestBody MarketTopic marketTopic) {
        MarketTopic marketTopic1 = adminTopicService.update(marketTopic);
        return BaseRespVo.ok(marketTopic1);
    }

    @RequestMapping("read")
    public BaseRespVo read(int id){
        MarketTopicGoods marketTopicGoods = adminTopicService.read(id);
        return BaseRespVo.ok(marketTopicGoods);
    }

}
